package thinkingJava.chapter14;

interface HasBatteries {}
interface Waterproof {}
interface Shoots {}

class Toy {
	Toy() {}
	Toy(int i) {}
}
class FancyToy extends Toy implements HasBatteries, Waterproof, Shoots {
	FancyToy() {
		super(1);
	}
}
/**
 * RTTI	Runtime Type Identification
 * @author Administrator
 *
 */
public class ToyTest {

	public static void printInfo(Class cc) {
		print("className : " + cc.getName() + " isInterface ? [" + cc.isInterface() + "]");
		print("simpleName : " + cc.getSimpleName());
		print("canonicalName : " + cc.getCanonicalName());
	}
	public static void main(String[] args) {
		Class c = null;
		try {
			c = Class.forName("thinkingJava.chapter14.FancyToy");
		} catch (ClassNotFoundException e) {
			print("could not found the class Fancytoy");
		}
		printInfo(c);
		for (Class face : c.getInterfaces()) {
			printInfo(face);
		}
		Class up = c.getSuperclass();
		printInfo(up);
		Object o = null;
		try {
			o = up.newInstance();
		} catch (InstantiationException e) {
			print("can not instantiantion");
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			print("can not access");
			e.printStackTrace();
		}
		print("--------------");
		printInfo(o.getClass());
	}
	public static void print(Object o) {
		System.out.println(o);
	}
}
